package HuaWeiOd.AA;

import java.util.Scanner;

/**
 * 输入单行英文句子，里面包含英文字母，空格以及.? 三种标点符号，请将句子内每个单词进行倒序，并输出倒序后的语句
 *
 * 输入描述:
 *
 * 输入字符串S，S的长度1≤N≤100
 *
 * 输出描述:
 *
 * 输出逆序后的字符串
 *
 * 补充说明:
 *
 * 标点符号左右的空格>=0，单词间空格 >0
 *
 *
 *
 * 示例1
 *
 * 输入:
 *
 * yM eman si boB.
 *
 * 输出:
 *
 * My name is Bob.
 *
 * 示例2
 *
 * 输入:
 *
 * woh era uoy ? I ma enif.
 *
 * 输出:
 *
 * how are you ? I am fine.
 * @author caihe
 * @date 2023/4/11 21:52
 */
public class 单词倒序 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        String[] arr = str.split(" ");
        for (String s : arr) {
            char[] chars = s.toCharArray();
            int left = 0;
            int right = chars.length - 1;
            while (left <= right) {
                char lc = chars[left];
                char rc = chars[right];
                if (lc == '.' || lc == '?') {
                    left++;
                    continue;
                }
                if (rc == '.' || rc == '?') {
                    right--;
                    continue;
                }
                char tmp = lc;
                chars[left] = rc;
                chars[right] = lc;
                left++;
                right--;
            }
            System.out.print(new String(chars) + " ");
        }
        
    }
}
